Top 10k strings from M-Code Library 1 - Screen Compression (1985)(16-48 Tape Magazine).z80 in <root> / bin / z80 / software / Sinclair Spectrum Collection TOSEC.exe / Sinclair ZX Spectrum - Utilities & Educational / Sinclair ZX Spectrum - Utilities & Educational - [Z80] (TOSEC-v2007-01-01) /

Back to the directory listing

   5 <<B||~<<><B
   5 <<B@B~<<><B
   3 ;"lib1code"
   2 ZERO COMPRESSION
   2 SCREEN COMPRESSION ROUTINE
   2 PRESS A KEY
   2 ;"library 1"
   2 "lib1code"
   2  copies.)"
   1 z$="10020203
   1 z$="04030104
   1 z$="00010502
   1 l=l+(l<max)*(k$="6"
   1 display subroutine
   1 Tw.)KK|_{_"
   1 STOP THE TAPE
   1 RUN THE TAPE
   1 M/CODE LIBRARY 1
   1 LET THE TAPE RUN
   1 GENERAL NOTES
   1 EXPANSION LISTING
   1 COMPRESSION LISTING
   1 ;"library 1":
   1 ;"We start our library with a muchrequested routine to compress   the display file."
   1 ;"Use up and down keys to read thenotes. 
   1 ;"The code starts at 32000 and it is 87 bytes long."
   1 ;"(Try BREAK and experiment.)
   1 32048 will expand the file back onto the screen."
   1 32000 will
   1 (a/256)"'"To display the file poke the    same two numbers into 32049 and 32050 respectively."
   1 '"When transferring the display   file to memory the routine will stop every time it finds a zero.After transferring the zero it  will count the number of zeros  which follow and transfer the   number it counts."
   1 '"To store the compressed file at any other address(a) you can-   POKE 32004,
   1 '"The compression routine stores  the compressed display file at  32090. LET x=
   1 '"The code is not relocatable. I  recommend using an assembler if you want to relocate.";#1
   1 '"RANDOMIZE 
   1 '"Any data containing blocks of   zeros (not just screens) can be compressed considerably using   this routine."
   1 "library 1"
   1 ","When all the zeros are done we  can do the next byte.","
   1 ","If the counter reaches 0(or 256)then exit from the count loop.","  DEC  BC","One less byte to do.","  LD   A,B","Check whether we have finished.","  OR   C","A will be 0 if BC=0.","  JR   NZ,
   1 ","If some zeros still left repeat this loop.","  JR   
   1 ","If not zero then go to the exit from the count routine.","  INC  HL","Point to the next byte.","  INC  E","Add 1 to the count."
   1 ","If not zero go back and do the next byte.","  PUSH DE","Save the pointer so that we can use E as a counter.","  LD   E,1","Set zero counter to 1."
   1 ","If counter is zero then we go   back and do the next byte.","
   1 ","If byte not zero then transfer  the next byte.","  LD   A,(HL)","If the last byte was zero this  one is the zero counter.","  INC  HL","Move the pointer on."
   1 ","If BC=0 then jump to exit.","  OR   A","Check byte for zero.","  JR   NZ,
   1 ","Exit if we have finished."
   1 ","Do the next byte."
   1 ","Carry on counting zeros if we   have not finished."
   1 "  POP   AF","Get the counter of the stack.","  DEC  A","decrement the counter.","  JR   NZ,
   1 "  OR   A","Check counter for zero.","  JR   Z,
   1 "  LD   HL,32090","Point HL at the compressed file.","  LD   DE,4000H","Point DE at the display file.","  LD   BC,6912","BC holds the length of the file when expanded."
   1 "  LD   HL,16384","Point HL at display file.","  LD   DE,32090","Point DE at storage location.","  LD   BC,6912","Put display file length in BC.","
   1 "  LD   A,E","Fetch the count.","  POP  DE","Get the pointer off the stack.","  DEC  A","Remove the original 1 from the  count.","  LD   (DE),A","Put the zero count in the
   1 "  JR   Z,
   1 "  JR   NZ,
   1 "  JP   PO,
   1 "  INC  DE","Point to the next location.","  DEC BC","One less left to do.","  LD   A,B","Check whether we have finished.","  OR   C","A will be 0 if BC=0.","  JR   Z,
   1  return with the end address of  the compressed file in x."
   1  perform the compression and
   1  for the menu, 
   1  compressed file.","
   1  PUSH DE","Put the last address of the fileon the stack.","  POP  BC","Fetch the final address into BC.","  RET","Back to basic." 
   1  PUSH AF","The zero loop starts here by    saving the the counter.","  LD   A,0","Fetch a zero.","  LD   (DE),A","Put a zero on the screen."
   1  POP  AF","Restore the Stack Pointer to thereturn address.","  RET","Back to Basic." 
   1  POKE 32005,a-256*
   1  LD   A,(HL)","Get the next byte.","  OR   A","Check for zero.","  JR   NZ,
   1  LD   A,(HL)","Fetch byte.","  LDI","Move (HL) to (DE), increment HL and DE, decrement BC.","  RET  PO","If BC=0 we have finished.","  OR   A","Check byte for zero."
   1  LD   A,(HL)","Fetch byte.","  LDI","Move (HL) to (DE), increment HL and DE, decrement BC."
   1  DEC  E","Remove the original 1.","  LD   A,E","A now holds the number of zeros to be added.","  POP  DE","Fetch the pointer.","  LD   (DE),A","Store the count.","  INC  DE","Point to the next space.","  JR